//
//  EYSelector.m
//  metadata
//
//  Created by easy on 11-5-27.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "EYSelector.h"


@implementation EYSelector
@synthesize ownSelector = own;
@synthesize name;

+(id) init:(SEL) selector{
	return [[[EYSelector alloc ]initWith:selector] autorelease];
}
-(id) initWith:(SEL) selector{
	if (self = [super init]) {
		own = selector;
	}
	return self;
}
+(id) registerWithName:(NSString *) name{ 
	return [EYSelector init:sel_registerName([name cStringUsingEncoding:DEFAULT_ENCODING])];
}
+(id) selectorWithUid:(NSString *)uid{ 
	return [EYSelector init:sel_getUid([uid cStringUsingEncoding:DEFAULT_ENCODING])];
}
+(BOOL) isEquals:(EYSelector *) sel1 to:(EYSelector *) sel2{
	return sel1 != nil && sel2 != nil && sel_isEqual(sel1.ownSelector, sel2.ownSelector);
}
-(BOOL) isEquals:(EYSelector *) sel{
	return [EYSelector isEquals:self to:sel];
}
#pragma mark -
#pragma mark setter/getter
-(NSString *) name{
	return [NSString stringWithCString:sel_getName(self.ownSelector) encoding:DEFAULT_ENCODING];
}

-(void) dealloc{
	own = nil;
	[super dealloc];
}
@end
